﻿Imports Oracle.DataAccess.Client
Imports System.Data.OleDb

Partial Class Usuarios
    Inherits System.Web.UI.Page
    Private x As Integer
    Private Cmd As OracleCommand
    Private dt As Data.DataTable
    Private Cnx As OracleConnection
    Private oradb As String = "Data Source=XE;User Id=SIRA;Password=SIRA123;"
    Private Sql As String
    Private Aux As String
    Private dr As OracleDataReader

    Protected Sub LiberarRecursos()
        Cnx.Close()
        dr.Dispose()
        Cmd.Dispose()
        Cnx.Dispose()
    End Sub

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Session("VarSessionUserIdCategoria") = 3 Then
            btnAgregar.Visible = False
            btnEliminar.Visible = False
            btnFiltrar.Visible = False
        End If
        lblUserNick.Text = Session("VarSessionUserNick")
        lblUserNombre.Text = Session("VarSessionUserNombre")
        lblUserIdCategoria.Text = Session("VarSessionUserIdCategoria")
        lblUserCategoria.Text = Session("VarSessionUserCategoria")
        lblUserIdComisaria.Text = Session("VarSessionUserIdComisaria")
        lblUserComisaria.Text = Session("VarSessionUserComisaria")
        lblUserIdNodo.Text = Session("VarSessionUserIdNodo")
        lblUserNodo.Text = Session("VarSessionUserNodo")
        lblUserIdUsuario.Text = Session("VarSessionUserIdUsuario")
        MostrarTablaUsuarios()
    End Sub
    Protected Sub MostrarTablaUsuarios()
        Cnx = New OracleConnection(oradb)

        If Session("VarSessionUserIdCategoria") = 3 Then
            'Es categoria 3 = Usuario
            Sql = "SELECT Usuarios.IdUsuario, Usuarios.Nombre, Usuarios.Nick, Comisarias.Descripcion, UsuariosCategorias.Categoria, TBL_Nodos.Descripcion " & _
                  "FROM UsuariosCategorias INNER JOIN (TBL_Nodos " & _
                  "INNER JOIN (Comisarias INNER JOIN Usuarios ON (Comisarias.IdComisaria=Usuarios.IdComisaria) " & _
                  "AND (Comisarias.IdNodo=Usuarios.IdNodo)) ON TBL_Nodos.IdNodo=Comisarias.IdNodo) " & _
                  "ON UsuariosCategorias.IdCategoria=Usuarios.IdCategoria " & _
                  "and Usuarios.IdUsuario = '" & Session("VarSessionUserIdCategoria") & "'"
        Else
            'Es categoria 1 o 2 = Administrador
            Sql = "SELECT Usuarios.IdUsuario, Usuarios.Nombre, Usuarios.Nick, Comisarias.Descripcion, UsuariosCategorias.Categoria, TBL_Nodos.Descripcion " & _
                  "FROM UsuariosCategorias INNER JOIN (TBL_Nodos " & _
                  "INNER JOIN (Comisarias INNER JOIN Usuarios ON (Comisarias.IdComisaria=Usuarios.IdComisaria) " & _
                  "AND (Comisarias.IdNodo=Usuarios.IdNodo)) ON TBL_Nodos.IdNodo=Comisarias.IdNodo) " & _
                  "ON UsuariosCategorias.IdCategoria=Usuarios.IdCategoria " & _
                  "and Usuarios.IdUsuario != 1 "
        End If
        Try
            Cnx.Open()
            Cmd = New OracleCommand(Sql, Cnx)
            Cmd.CommandType = Data.CommandType.Text
            dr = Cmd.ExecuteReader()
            If Not IsPostBack Then
                While dr.Read()
                    DDLNombres.Items.Add(dr.Item("DESCRIPCION"))
                    DDLEliminar.Items.Add(dr.Item("DESCRIPCION"))
                End While

            End If
            dr = Cmd.ExecuteReader()
            GV2.DataSource = dr
            GV2.DataBind()
        Catch ex As Exception
            MsgBox(ex.Message.ToString())
        Finally
        End Try
        LiberarRecursos()
    End Sub

    Protected Sub btnAgregar_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnAgregar.Click
        PanelSeleccion.Visible = False
        PanelFiltro.Visible = False
        PanelEliminar.Visible = False
        PanelEdicion.Visible = True
        ViewState("Accion") = "Agregar"
        LimpiarPanelEdicion()
        CargarDDLNodos()
        CargarDDLComisarias()
        CargarDDLCategorias()
    End Sub

    Protected Sub btnEditar_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnEditar.Click
        PanelSeleccion.Visible = True
        PanelFiltro.Visible = False
        PanelEliminar.Visible = False
        PanelEdicion.Visible = False
        ViewState("Accion") = "Editar"
        If Session("VarSessionUserIdCategoria") = 3 Then
            DDLNodos.Visible = False
            DDLCategorias.Visible = False
            DDLComisarias.Visible = False
        End If
        CargarDDLNombres_y_DDLEliminar()
        CargarDDLCategorias()
        CargarDDLNodos()
        CargarDDLComisarias()
    End Sub
    Protected Sub btnEliminar_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnEliminar.Click
        PanelSeleccion.Visible = False
        PanelFiltro.Visible = False
        PanelEliminar.Visible = True
        PanelEdicion.Visible = False
        ViewState("Accion") = "Eliminar"
    End Sub
    Protected Sub btnFiltrar_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnFiltrar.Click
        PanelSeleccion.Visible = False
        PanelFiltro.Visible = True
        PanelEliminar.Visible = False
        PanelEdicion.Visible = False
        ViewState("Accion") = "Filtrar"
        CargarDDLCampos()
    End Sub
    Protected Sub btnAbortar_Click(ByVal sender As Object, ByVal e As System.EventArgs) _
    Handles btnSalir.Click, btnSalirPanelEdicion.Click, btnSalirPanelEliminar.Click, btnSalirPanelFiltro.Click
        PanelSeleccion.Visible = False
        PanelEdicion.Visible = False
        PanelEliminar.Visible = False
        PanelFiltro.Visible = False
        ViewState("Accion") = ""
    End Sub
    Protected Sub LimpiarPanelEdicion()
        txtNombre.Text = ""
        txtNick.Text = ""
        txtIdNodo.Text = ""
        txtIdCategoria.Text = ""
        txtIdComisaria.Text = ""
        txtPassword.Text = ""
        DDLNombres.SelectedIndex = 0
    End Sub

    Protected Sub btnRecuperar_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnRecuperar.Click
        DDLNodos.SelectedIndex = 0
        DDLCategorias.SelectedIndex = 0
        DDLComisarias.SelectedIndex = 0
        txtNombre.Text = ViewState("Descripcion")
        txtNick.Text = ViewState("Nick")
        txtIdNodo.Text = ViewState("IdNodo")
        txtIdCategoria.Text = ViewState("IdCategoria")
        txtIdComisaria.Text = ViewState("IdComisaria")
        txtPassword.Text = ViewState("Password")
    End Sub

    Protected Sub CargarDDLNodos()
        Cnx = New OracleConnection(oradb)
        Sql = "select * from TBL_Nodos"
        DDLNodos.Items.Clear()
        Try
            Cnx.Open()
            Cmd = New OracleCommand(Sql, Cnx)
            Cmd.CommandType = Data.CommandType.Text
            Cmd.ExecuteNonQuery()
            dr = Cmd.ExecuteReader()
            DDLNodos.Items.Add("Su Elección")
            While dr.Read()
                DDLNodos.Items.Add(dr.Item("Descripcion"))
            End While
        Catch ex As Exception
            MsgBox(ex.Message.ToString())
        Finally
        End Try
        LiberarRecursos()
    End Sub
    Protected Sub ObtenerIdNodo()
        Cnx = New OracleConnection(oradb)
        Sql = "select * from TBL_Nodos WHERE Descripcion = '" & DDLNodos.SelectedValue & "'"
        Try
            Cnx.Open()
            Cmd = New OracleCommand(Sql, Cnx)
            Cmd.CommandType = Data.CommandType.Text
            Cmd.ExecuteNonQuery()
            dr = Cmd.ExecuteReader()
            If dr.Read() Then
                Aux = dr.Item("IdNodo")
            Else
                MsgBox("No puedo encontrar IdNodo en tabla TBL_Nodos" & vbCrLf, MsgBoxStyle.Critical, _
                       "Error proceso ObtenerIdNodo - Usuarios.aspx")
                LiberarRecursos()
                Exit Sub
            End If
        Catch ex As Exception
            MsgBox("No puedo abrir tabla TBL_Nodos" & vbCrLf & ex.Message, MsgBoxStyle.Critical, _
                   "Error proceso ObtenerIdNodo - Usuarios.aspx")
        Finally
        End Try
        LiberarRecursos()
    End Sub

    Protected Sub CargarDDLComisarias()
        Cnx = New OracleConnection(oradb)
        Sql = "select * from Comisarias"
        DDLComisarias.Items.Clear()
        Try
            Cnx.Open()
            Cmd = New OracleCommand(Sql, Cnx)
            Cmd.CommandType = Data.CommandType.Text
            Cmd.ExecuteNonQuery()
            dr = Cmd.ExecuteReader()
            DDLComisarias.Items.Add("Su Elección")
            While dr.Read()
                DDLComisarias.Items.Add(dr.Item("Descripcion"))
            End While
        Catch ex As Exception
            MsgBox(ex.Message.ToString())
        Finally
        End Try
        LiberarRecursos()
    End Sub
    Protected Sub ObtenerIdComisaria()
        Cnx = New OracleConnection(oradb)
        Sql = "select * from Comisarias WHERE Descripcion = '" & DDLComisarias.SelectedValue & "'"
        Try
            Cnx.Open()
            Cmd = New OracleCommand(Sql, Cnx)
            Cmd.CommandType = Data.CommandType.Text
            Cmd.ExecuteNonQuery()
            dr = Cmd.ExecuteReader()
            If dr.Read() Then
                Aux = dr.Item("IdComisaria")
            Else
                MsgBox("No puedo encontrar IdComisaria en tabla Comisarias" & vbCrLf, MsgBoxStyle.Critical, _
                       "Error proceso ObtenerIdComisaria - Usuarios.aspx")
                LiberarRecursos()
                Exit Sub
            End If
        Catch ex As Exception
            MsgBox("No puedo abrir tabla Comisarias" & vbCrLf & ex.Message, MsgBoxStyle.Critical, _
                   "Error proceso ObtenerIdComisaria - Usuarios.aspx")
        Finally
        End Try
        LiberarRecursos()
    End Sub

    Protected Sub CargarDDLCategorias()
        Cnx = New OracleConnection(oradb)
        Sql = "select * from UsuariosCategorias"
        DDLCategorias.Items.Clear()
        Try
            Cnx.Open()
            Cmd = New OracleCommand(Sql, Cnx)
            Cmd.CommandType = Data.CommandType.Text
            Cmd.ExecuteNonQuery()
            dr = Cmd.ExecuteReader()
            DDLCategorias.Items.Add("Su Elección")
            While dr.Read()
                DDLCategorias.Items.Add(dr.Item("Categoria"))
            End While
        Catch ex As Exception
            MsgBox(ex.Message.ToString())
        Finally
        End Try
        LiberarRecursos()
    End Sub
    Protected Sub ObtenerIdCategoria()
        Cnx = New OracleConnection(oradb)
        Sql = "select * from UsuariosCategorias WHERE Categoria = '" & DDLCategorias.SelectedValue & "'"
        Try
            Cnx.Open()
            Cmd = New OracleCommand(Sql, Cnx)
            Cmd.CommandType = Data.CommandType.Text
            Cmd.ExecuteNonQuery()
            dr = Cmd.ExecuteReader()
            If dr.Read() Then
                Aux = dr.Item("IdCategoria")
            Else
                MsgBox("No puedo encontrar IdCategoria en tabla UsuariosCategorias" & vbCrLf, MsgBoxStyle.Critical, _
                       "Error proceso ObtenerIdCategoria - Usuarios.aspx")
                LiberarRecursos()
                Exit Sub
            End If
        Catch ex As Exception
            MsgBox("No puedo abrir tabla UsuariosCategorias" & vbCrLf & ex.Message, MsgBoxStyle.Critical, _
                   "Error proceso ObtenerIdCategoria - Usuarios.aspx")
        Finally
        End Try
        LiberarRecursos()
    End Sub

    Protected Sub CargarDDLNombres_y_DDLEliminar()
        Cnx = New OracleConnection(oradb)
        If Session("VarSessionUserIdCategoria") = 3 Then
            Sql = "select * from Usuarios where IdUsuario = '" & Session("VarSessionUserIdCategoria") & "'"
        Else
            Sql = "select * from Usuarios where IdUsuario != 1 ORDER BY Nombre ASC"
        End If
        DDLNombres.Items.Clear()
        DDLEliminar.Items.Clear()
        Try
            Cnx.Open()
            Cmd = New OracleCommand(Sql, Cnx)
            Cmd.CommandType = Data.CommandType.Text
            Cmd.ExecuteNonQuery()
            dr = Cmd.ExecuteReader()
            DDLNombres.Items.Add("Su Elección")
            DDLEliminar.Items.Add("Su Elección")
            While dr.Read()
                DDLNombres.Items.Add(dr.Item("Nombre"))
                DDLEliminar.Items.Add(dr.Item("Nombre"))
            End While
            DDLNombres.SelectedIndex = 0
            DDLEliminar.SelectedIndex = 0
        Catch ex As Exception
            MsgBox(ex.Message.ToString())
        Finally
        End Try
        LiberarRecursos()
    End Sub
    Protected Sub CargarDDLCampos()
        Cnx = New OracleConnection(oradb)
        Sql = "select * from Usuarios"
        DDLCampos.Items.Clear()
        Try
            Cnx.Open()
            Cmd = New OracleCommand(Sql, Cnx)
            Cmd.CommandType = Data.CommandType.Text
            Cmd.ExecuteNonQuery()
            dr = Cmd.ExecuteReader()
            DDLCampos.Items.Add("Su Elección")
            For x = 0 To dr.FieldCount - 1
                DDLCampos.Items.Add(dr.GetName(x))
            Next
        Catch ex As Exception
            MsgBox(ex.Message.ToString())
        Finally
        End Try
        LiberarRecursos()
    End Sub

    Protected Sub btnAceptar_Click(ByVal sender As Object, ByVal e As System.EventArgs) _
    Handles btnAceptarEdicion.Click, btnAceptarPanelEliminar.Click
        If Page.IsValid Then
        Else
            labelMessage.Text = "Error en carga de datos-Proceso ControlCampos-Usuarios.aspx"
            Exit Sub
        End If

        If txtNombre.Text.Length = 0 Then
            labelMessage.Text = "Nombre : no puede ser NULL"
            Exit Sub
        End If
        If txtNick.Text.Length = 0 Then
            labelMessage.Text = "Nick : no puede ser NULL"
            Exit Sub
        End If
        If txtPassword.Text.Length < 2 Then
            labelMessage.Text = "Minima longitud para contraseña = 2"
            Exit Sub
        End If
        If DDLNodos.SelectedIndex = 0 Then
            labelMessage.Text = "Falta seleccionar Nodo"
            Exit Sub
        End If
        If DDLComisarias.SelectedIndex = 0 Then
            labelMessage.Text = "Falta seleccionar Comisaria"
            Exit Sub
        End If
        If DDLCategorias.SelectedIndex = 0 Then
            labelMessage.Text = "Falta seleccionar Comisaria"
            Exit Sub
        End If

        Cnx = New OracleConnection(oradb)
        Cnx.Open()
        Select Case ViewState("Accion")
            Case "Editar"
                Try
                    Sql = "UPDATE Usuarios set " & _
                          "Nombre='" & txtNombre.Text & "'," & _
                          "Nick='" & txtNick.Text & "'," & _
                          "IdNodo='" & txtIdNodo.Text & "'," & _
                          "IdCategoria='" & txtIdCategoria.Text & "'," & _
                          "IdComisaria='" & txtIdComisaria.Text & "'," & _
                          "Password='" & txtPassword.Text & _
                          "' WHERE IdUsuario='" & ViewState("IdUsuario") & "'"
                    Cmd = New OracleCommand(Sql, Cnx)
                    Cmd.ExecuteNonQuery()
                Catch ex As Exception
                    MsgBox("No puedo Actualizar (UPDATE) tabla Usuarios " & vbCrLf & ex.Message, MsgBoxStyle.Critical, _
                           "Error proceso btnAceptar_Click panel Edicion btnAceptarEdicion - Usuarios.aspx")
                Finally
                End Try
                LiberarRecursos()
                MostrarTablaUsuarios()
                CargarDDLNombres_y_DDLEliminar()
                CargarDDLNodos()
            Case "Eliminar"
                If DDLEliminar.SelectedValue = "Su Elección" Then
                    lblCrtlDDLEliminar.Visible = True
                    Exit Sub
                Else
                    lblCrtlDDLEliminar.Visible = False
                End If
                Try
                    Sql = "DELETE FROM Usuarios WHERE Nombre='" & DDLEliminar.SelectedValue & "'"
                    Cmd = New OracleCommand(Sql, Cnx)
                    Cmd.ExecuteNonQuery()
                Catch ex As Exception
                    MsgBox("No puedo ejecutar : DELETE FROM Usuarios WHERE Nombre='" & DDLEliminar.SelectedValue & "'" & vbCrLf & ex.Message, MsgBoxStyle.Critical, _
                           "Error proceso btnAceptar_Click panel Eliminar btnAceptarPanelEliminar - Usuarios.aspx")
                Finally
                End Try
                LiberarRecursos()
                MostrarTablaUsuarios()
                CargarDDLNombres_y_DDLEliminar()
                CargarDDLNodos()
            Case "Agregar"
                Try
                    Sql = "INSERT INTO Usuarios (Nombre,Nick,IdCategoria,IdComisaria,IdNodo,Password) VALUES (" & _
                          "'" & txtNombre.Text & "'," & _
                          "'" & txtNick.Text & "'," & _
                          "'" & txtIdCategoria.Text & "'," & _
                          "'" & txtIdComisaria.Text & "'," & _
                          "'" & txtIdNodo.Text & "'," & _
                          "'" & txtPassword.Text & "')"
                    Cmd = New OracleCommand(Sql, Cnx)
                    Cmd.ExecuteNonQuery()
                Catch ex As Exception
                    MsgBox("No puedo Agregar (INSERT INTO) tabla Usuarios " & vbCrLf & ex.Message, MsgBoxStyle.Critical, _
                           "Error proceso btnAceptar_Click panel Agregar btnAceptarEdicion - Usuarios.aspx")
                Finally
                End Try
                LiberarRecursos()
                LimpiarPanelEdicion()
                MostrarTablaUsuarios()
                CargarDDLNombres_y_DDLEliminar()
                CargarDDLNodos()
        End Select
        PanelFiltro.Visible = False
        PanelEliminar.Visible = False
        PanelEdicion.Visible = False
    End Sub

    Protected Sub DDLCampos_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) _
    Handles DDLCampos.SelectedIndexChanged
        If DDLCampos.SelectedValue = "Su Elección" Then
            Exit Sub
        End If
        Cnx = New OracleConnection(oradb)
        Try
            Cnx.Open()
            Sql = "SELECT DISTINCT " & DDLCampos.SelectedValue & " FROM Usuarios ORDER BY " & DDLCampos.SelectedValue & " ASC"
            Cmd = New OracleCommand(Sql, Cnx)
            DDLDatos.Items.Clear()
            DDLDatos.Items.Add("Su Elección")
            dr = Cmd.ExecuteReader()
            While dr.Read()
                DDLDatos.Items.Add(dr.Item(0))
            End While
        Catch ex As Exception
            MsgBox("No puedo abrir recordset = SELECT DISTINCT " & DDLCampos.SelectedValue & " FROM Usuarios ORDER BY " & DDLCampos.SelectedValue & " ASC" & vbCrLf & ex.Message, MsgBoxStyle.Critical, _
                   "Error proceso DDLCampos_SelectedIndexChanged - Usuarios.aspx")
        Finally
        End Try
        LiberarRecursos()
        txtSQL.Text = "SELECT * FROM Usuarios WHERE Usuarios." & DDLCampos.SelectedValue & " "
    End Sub
    Protected Sub DDL_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) _
    Handles DDLNodos.SelectedIndexChanged, DDLCategorias.SelectedIndexChanged, DDLComisarias.SelectedIndexChanged
        If sender.SelectedValue = "Su Elección" Then
            Exit Sub
        End If
        Select Case sender.id
            Case "DDLNodos" : ObtenerIdNodo() : txtIdNodo.Text = Aux
            Case "DDLCategorias" : ObtenerIdCategoria() : txtIdCategoria.Text = Aux
            Case "DDLComisarias" : ObtenerIdComisaria() : txtIdComisaria.Text = Aux
        End Select
    End Sub
    Protected Sub btnAceptarFiltro_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnAceptarFiltro.Click
        Cnx = New OracleConnection(oradb)
        Sql = "select * from Usuarios"
        Try
            Cnx.Open()
            Cmd = New OracleCommand(txtSQL.Text, Cnx)
            Cmd.CommandType = Data.CommandType.Text
            dr = Cmd.ExecuteReader()
            GV2.DataSource = dr
            GV2.DataBind()
        Catch ex As Exception
            MsgBox(ex.Message.ToString())
        Finally
        End Try
        LiberarRecursos()
    End Sub

    Protected Sub DDLFiltro_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) _
    Handles DDLLogicos.SelectedIndexChanged, DDLDatos.SelectedIndexChanged
        If DDLCampos.SelectedValue = "Su Elección" Then
            MsgBox("Seleccione que campo usar." & vbCrLf, MsgBoxStyle.Critical, "Error proceso DDLFiltro_SelectedIndexChanged - Usuarios.aspx")
            lblCampo.Visible = True
            Exit Sub
        End If
        lblCampo.Visible = False
        If DDLLogicos.SelectedValue = "Su Elección" Then
            MsgBox("Seleccione que operador lógico usar." & vbCrLf, MsgBoxStyle.Critical, _
                   "Error proceso DDLFiltro_SelectedIndexChanged - Usuarios.aspx")
            lblLogico.Visible = True
            Exit Sub
        End If
        Select Case sender.id
            Case "DDLLogicos"
                lblLogico.Visible = False
                txtSQL.Text = txtSQL.Text & " " & DDLLogicos.SelectedValue
            Case "DDLDatos"
                lblDato.Visible = False
                txtSQL.Text = txtSQL.Text & " '" & DDLDatos.SelectedValue & "' "
        End Select
    End Sub

    Protected Sub btnLimpiarSQL_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnLimpiarSQL.Click
        txtSQL.Text = ""
        DDLCampos.SelectedIndex = 0
        DDLLogicos.SelectedIndex = 0
        DDLDatos.SelectedIndex = 0
    End Sub

    Protected Sub DDLUsuarioEliminar_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DDLEliminar.SelectedIndexChanged
        If DDLEliminar.SelectedValue = "Su Elección" Then
            Exit Sub
        End If
    End Sub

    Protected Sub AceptarPanelSeleccion(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnAceptarSeleccion.Click
        If DDLNombres.SelectedValue = "Su Elección" Then
            lblCrtlDDLNombre.Visible = True
            PanelEdicion.Visible = False
            Exit Sub
        Else
            lblCrtlDDLNombre.Visible = False
            PanelEdicion.Visible = True
        End If
        PanelEdicion.Visible = True
        Cnx = New OracleConnection(oradb)
        Sql = "select * from Usuarios WHERE Nombre = '" & DDLNombres.SelectedValue & "'"
        Try
            Cnx.Open()
            Cmd = New OracleCommand(Sql, Cnx)
            Cmd.CommandType = Data.CommandType.Text
            dr = Cmd.ExecuteReader()
            dr.Read()
            ViewState("IdUsuario") = dr.Item("IdUsuario")
            txtNombre.Text = dr.Item("Nombre") : ViewState("Nombre") = dr.Item("Nombre")
            txtNick.Text = dr.Item("Nick") : ViewState("Nick") = dr.Item("Nick")
            txtIdNodo.Text = dr.Item("IdNodo") : ViewState("IdNodo") = dr.Item("IdNodo")
            txtIdCategoria.Text = dr.Item("IdCategoria") : ViewState("IdCategoria") = dr.Item("IdCategoria")
            txtIdComisaria.Text = dr.Item("IdComisaria") : ViewState("IdComisaria") = dr.Item("IdComisaria")
            txtPassword.Text = dr.Item("Password") : ViewState("Password") = dr.Item("Password")
        Catch ex As Exception
            MsgBox("No puedo abrir tabla Usuarios " & vbCrLf & ex.Message, MsgBoxStyle.Critical, _
                   "Error proceso AceptarPanelSeleccion - Usuarios.aspx")
            MsgBox(ex.Message.ToString())
        Finally
        End Try
        LiberarRecursos()
    End Sub

    Protected Sub btnCalcWin_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnCalcWin.Click
        Dim Proceso As New Diagnostics.Process()
        Proceso.StartInfo.FileName = "calc.exe"
        Proceso.StartInfo.Arguments = ""
        Proceso.Start()
    End Sub

    Protected Sub DDLNombre_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DDLNombres.SelectedIndexChanged

    End Sub
End Class
